﻿@using ETD.Common.Extension;
@using ETD.WebOrganization.Libs.Helper;
@using ETD.WinClient.Config;
@using ETD.Domain.EnumModels;
@{

}

<script>
    var StringHelper = {};
    StringHelper.isPhoneAvailable = function (poneInput) {
        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(poneInput)) {
            return false;
        } else {
            return true;
        }
    }
    StringHelper.isNullOrEmpty = function (str) {
        if (str == null) return true;
        if (str.trim() == "") return true;
        return false;
    }
    StringHelper.isVaildEntityID = function (str) {
        if (StringHelper.isNullOrEmpty(str)) return false;
        if (str > 0) {
            return true;
        }
        return false;
    }

    StringHelper.decimalF2 = function (num) {
        var result = parseFloat(num);
        if (isNaN(result)) {
            return 0;
        }
        result = Math.round(num * 100) / 100;
        var s_x = result.toString();
        var pos_decimal = s_x.indexOf('.');
        if (pos_decimal < 0) {
            pos_decimal = s_x.length;
            s_x += '.';
        }
        while (s_x.length <= pos_decimal + 2) {
            s_x += '0';
        }
        return s_x;
    }

</script>
<script>
    var InputHelper = {};
    InputHelper.numInput = function (input) {
        function makeValueToF2(ctlValue) {
            if (ctlValue == null) return "";
            ctlValue = ctlValue.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
            ctlValue = ctlValue.replace(/^\./g, ""); //验证第一个字符是数字
            ctlValue = ctlValue.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
            ctlValue = ctlValue.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            ctlValue = ctlValue.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
            return ctlValue;
        }
        $("#" + input).on("keyup", function () {
            var ctlValue = $(this).val();
            ctlValue = makeValueToF2(ctlValue);
            console.log("ctlValue=" + ctlValue);
            $(this).val(ctlValue);
        });
        var ctlValue = $("#" + input).val();
        $("#" + input).val(makeValueToF2(ctlValue));
    }
</script>
<script>
    var WinHelper = {};
    WinHelper.timestamp = function () {
        var date = new Date();
        this.year = date.getFullYear();
        this.month = date.getMonth() + 1;
        this.month = this.month < 10 ? "0" + this.month : this.month;
        this.date = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
        this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
        this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        this.millisecond = date.getTime().toString().substring(10, 13);
        //2019 04 10 18 01 14 623
        var currentTime = "" + this.year + this.month + this.date + this.hour + this.minute + this.second + this.millisecond;
        return currentTime;
    }
    WinHelper.redirect = function (url) {
        var timestamp = WinHelper.timestamp();
        if (url.indexOf("?") > -1) {
            url = url + "&timestamp=" + timestamp;
        } else {
            url = url + "?timestamp=" + timestamp;
        }
        console.log("WinHelper.redirect=" + url);
        window.location.href = url;
    };
    WinHelper.urlWrap = function (url) {
        var timestamp = WinHelper.timestamp();
        if (url.indexOf("?") > -1) {
            url = url + "&timestamp=" + timestamp;
        } else {
            url = url + "?timestamp=" + timestamp;
        }
        console.log("WinHelper.urlWrap=" + url);
        return url;
    };
    WinHelper.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    WinHelper.isWeiXin = function () {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            return true;
        } else {
            return false;
        }
    }
    WinHelper.getUrlParamByUrl = function (url, name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        if (url == null) return null;
        if (url.indexOf("?") == -1) return null;
        var para = url.substr(url.indexOf("?"));
        var r = para.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

</script>
<script>
    var TimeHelper = {};
    TimeHelper.fomatTime = function (data,format) {
        var datetime = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), 10));
        var year = datetime.getFullYear();
        var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
        var currentDate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
        var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
        var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
        var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
        if (format == "ymdhms") {
            return year + "-" + month + "-" + currentDate + " " + hour + ":" + minute + ":" + second;
        }
        else if (format == "ymdhm") {
            return year + "-" + month + "-" + currentDate + " " + hour + ":" + minute;
        }
        else if (format == "ymd") {
            return year + "-" + month + "-" + currentDate;
        }
    }
    TimeHelper.ymdTime = function (data) {
        if (!data) return "--";
        return TimeHelper.fomatTime(data, "ymd");
    }
    TimeHelper.ymdhmTime = function (data) {
        if (!data) return "--";
        return TimeHelper.fomatTime(data, "ymdhm");
    }
    TimeHelper.ymdhmsTime = function (data) {
        if (!data) return "--";
        return TimeHelper.fomatTime(data, "ymdhms");
    }
</script>
<script>
    function BaseVue() { };
    function initBaseVue(BaseVue) {
        BaseVue.prototype.scrollBottom = function (vue) {
            let self = vue;
            window.setTimeout(function () {
                // 滚动到页面底部时，请求前一天的文章内容
                $(window).scroll(function () {
                    if (self.hasMore == false) return;
                    let scrollTop = $(window).scrollTop();
                    let windowTop = $(window).height();
                    let documentTop = $(document).height();
                    console.log("documentTop - windowTop=" + (documentTop - windowTop));
                    console.log("scrollTop=" + scrollTop);
                    if (documentTop - windowTop <= scrollTop) {
                        // 请求的数据未加载完成时，滚动到底部不再请求前一天的数据
                        self.hasMore = false;
                        self.loading = true;
                        self.loadingText = '努力加载中...';
                        self.page++;
                        self.getItemList();
                    }
                });
            }, 500);
        };
    }
    initBaseVue(BaseVue);
</script>